<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>android实战 | 月藤的博客</title>
    <meta name="generator" content="VuePress 1.8.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css">
    <meta name="description" content="简单的介绍">
    
    <link rel="preload" href="/assets/css/0.styles.a2e941e0.css" as="style"><link rel="preload" href="/assets/js/app.54ea76a2.js" as="script"><link rel="preload" href="/assets/js/2.c554ece5.js" as="script"><link rel="preload" href="/assets/js/13.9096527c.js" as="script"><link rel="prefetch" href="/assets/js/10.95d63e51.js"><link rel="prefetch" href="/assets/js/11.26e082be.js"><link rel="prefetch" href="/assets/js/12.1f62021c.js"><link rel="prefetch" href="/assets/js/14.86142c70.js"><link rel="prefetch" href="/assets/js/15.1adeebc5.js"><link rel="prefetch" href="/assets/js/16.efcc79e4.js"><link rel="prefetch" href="/assets/js/17.74da5698.js"><link rel="prefetch" href="/assets/js/18.fd808b3a.js"><link rel="prefetch" href="/assets/js/19.8dafe26f.js"><link rel="prefetch" href="/assets/js/20.aed54ab4.js"><link rel="prefetch" href="/assets/js/21.341a5670.js"><link rel="prefetch" href="/assets/js/22.ab8b375c.js"><link rel="prefetch" href="/assets/js/23.28489470.js"><link rel="prefetch" href="/assets/js/24.87aae001.js"><link rel="prefetch" href="/assets/js/25.211ca3bf.js"><link rel="prefetch" href="/assets/js/26.afa4c8f0.js"><link rel="prefetch" href="/assets/js/27.9b98f6f3.js"><link rel="prefetch" href="/assets/js/28.93298733.js"><link rel="prefetch" href="/assets/js/29.e8c038c4.js"><link rel="prefetch" href="/assets/js/3.9d562ae1.js"><link rel="prefetch" href="/assets/js/30.27939f01.js"><link rel="prefetch" href="/assets/js/31.6a9774e8.js"><link rel="prefetch" href="/assets/js/32.f698e967.js"><link rel="prefetch" href="/assets/js/33.5ba4bfb8.js"><link rel="prefetch" href="/assets/js/34.dca90861.js"><link rel="prefetch" href="/assets/js/35.768c1bb2.js"><link rel="prefetch" href="/assets/js/36.6b0a867f.js"><link rel="prefetch" href="/assets/js/37.61156e90.js"><link rel="prefetch" href="/assets/js/38.e390246c.js"><link rel="prefetch" href="/assets/js/39.0fbd0dd1.js"><link rel="prefetch" href="/assets/js/4.e18bc6a8.js"><link rel="prefetch" href="/assets/js/40.4252699c.js"><link rel="prefetch" href="/assets/js/41.2e5b5840.js"><link rel="prefetch" href="/assets/js/42.8fe886c7.js"><link rel="prefetch" href="/assets/js/43.7a4b0851.js"><link rel="prefetch" href="/assets/js/44.93c2313d.js"><link rel="prefetch" href="/assets/js/45.33dcea60.js"><link rel="prefetch" href="/assets/js/46.681fdf10.js"><link rel="prefetch" href="/assets/js/47.a842a141.js"><link rel="prefetch" href="/assets/js/48.9a03ba74.js"><link rel="prefetch" href="/assets/js/49.a50266b1.js"><link rel="prefetch" href="/assets/js/5.dc6a2d8c.js"><link rel="prefetch" href="/assets/js/50.f2a42406.js"><link rel="prefetch" href="/assets/js/51.444cc3d8.js"><link rel="prefetch" href="/assets/js/52.cf2befd8.js"><link rel="prefetch" href="/assets/js/53.fbe609f8.js"><link rel="prefetch" href="/assets/js/54.a43fb514.js"><link rel="prefetch" href="/assets/js/55.d0c11641.js"><link rel="prefetch" href="/assets/js/56.c6f114d9.js"><link rel="prefetch" href="/assets/js/57.cc386420.js"><link rel="prefetch" href="/assets/js/58.e747d0f6.js"><link rel="prefetch" href="/assets/js/6.c1fd48f0.js"><link rel="prefetch" href="/assets/js/7.32b39b92.js"><link rel="prefetch" href="/assets/js/8.e2284671.js"><link rel="prefetch" href="/assets/js/9.8def3992.js">
    <link rel="stylesheet" href="/assets/css/0.styles.a2e941e0.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">月藤的博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://ziphold.gitee.io/blog/#/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  旧博客（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://rattonlzh.github.io/homepage/homepage.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  常用网址导航（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/开发资料/android学习资料.html" class="nav-link">
  zh-CN
</a></li><li class="dropdown-item"><!----> <a href="/en/" class="nav-link">
  en-US
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><div class="avatar"><img src="/assets/img/avatar.2b77755b.png" alt srcset></div> <div style="z-index: 999"><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="298" height="52" src="//music.163.com/outchain/player?type=2&id=28283137&auto=1&height=32"></iframe></div> <nav class="nav-links"><div class="nav-item"><a href="https://ziphold.gitee.io/blog/#/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  旧博客（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://rattonlzh.github.io/homepage/homepage.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  常用网址导航（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/开发资料/android学习资料.html" class="nav-link">
  zh-CN
</a></li><li class="dropdown-item"><!----> <a href="/en/" class="nav-link">
  en-US
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>随便说说</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>知识点总结</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>考研专区</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>读书笔记</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>开发资料</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/开发资料/android学习资料.html" class="active sidebar-link">android实战</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#学习资源" class="sidebar-link">学习资源</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#数据传递" class="sidebar-link">数据传递</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#从系统选择文本文件" class="sidebar-link">从系统选择文本文件</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#常用文件后缀对应的mime类型" class="sidebar-link">常用文件后缀对应的MIME类型</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#解析uri-读取文本文件" class="sidebar-link">解析uri，读取文本文件</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#handler事件分发" class="sidebar-link">handler事件分发</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#文件存储的默认位置" class="sidebar-link">文件存储的默认位置</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#文件读写模式" class="sidebar-link">文件读写模式</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#文件的读写" class="sidebar-link">文件的读写</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#外部存储的读写" class="sidebar-link">外部存储的读写</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#获取输入框的内容并检查" class="sidebar-link">获取输入框的内容并检查</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#pull解析xml文件" class="sidebar-link">PULL解析XML文件</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#gson库解析json文件" class="sidebar-link">Gson库解析json文件</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#sharedpreferences的使用" class="sidebar-link">SharedPreferences的使用</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#创建sqlite数据库帮助类" class="sidebar-link">创建SQLite数据库帮助类</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#配置butterknife10-2-0" class="sidebar-link">配置ButterKnife10.2.0</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#在fragment中使用butterknife" class="sidebar-link">在Fragment中使用ButterKnife</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#在fragment设置监听事件" class="sidebar-link">在Fragment设置监听事件</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#同一个activity的fragment的跳转" class="sidebar-link">同一个Activity的fragment的跳转</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#在fragment中获取跳转的activity返回的结果" class="sidebar-link">在fragment中获取跳转的activity返回的结果</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#再按一次退出程序" class="sidebar-link">再按一次退出程序</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#权限的动态申请" class="sidebar-link">权限的动态申请</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#常用权限" class="sidebar-link">常用权限</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#加载svg资源" class="sidebar-link">加载svg资源</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#设置app图标" class="sidebar-link">设置App图标</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#recyclerview使用" class="sidebar-link">RecyclerView使用</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#fragment生命周期" class="sidebar-link">Fragment生命周期</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#访问网络" class="sidebar-link">访问网络</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#handler-信息机制" class="sidebar-link">Handler 信息机制</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#创建图片对象" class="sidebar-link">创建图片对象</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#推荐的android应用架构" class="sidebar-link">推荐的android应用架构</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#uri与string互转" class="sidebar-link">Uri与String互转</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#animation" class="sidebar-link">animation</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#阿里源镜像仓库" class="sidebar-link">阿里源镜像仓库</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#注释保持缩进对齐" class="sidebar-link">注释保持缩进对齐：</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#查看类的定义" class="sidebar-link">查看类的定义</a></li><li class="sidebar-sub-header"><a href="/开发资料/android学习资料.html#使用resource-manager添加图片资源" class="sidebar-link">使用resource manager添加图片资源</a></li></ul></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>配置记录</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>思维导图</span> <span class="arrow right"></span></p> <!----></section></li><li><a href="/friend_link.html" class="sidebar-link">友情链接</a></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="android-实战"><a href="#android-实战" class="header-anchor">#</a> android 实战</h1> <blockquote><p>目录</p> <p>[TOC]</p></blockquote> <h2 id="学习资源"><a href="#学习资源" class="header-anchor">#</a> 学习资源</h2> <p><a href="https://www.dev2qa.com/android-shape-selector-examples/" target="_blank" rel="noopener noreferrer">shape与selector<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/a663803b2a44" target="_blank" rel="noopener noreferrer">底部tab菜单栏<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://github.com/zhujun2730/Android-Learning-Resources" target="_blank" rel="noopener noreferrer">学习资源大全<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://flutterchina.club/" target="_blank" rel="noopener noreferrer">Flutter中文网<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://camposha.info/flutter-sqflite-insertselectshow/" target="_blank" rel="noopener noreferrer">Flutter SQFLite 执行CURD<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/kotlin/resources" target="_blank" rel="noopener noreferrer">Kotlin学习资源<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://github.com/enbandari/Kotlin-Tutorials" target="_blank" rel="noopener noreferrer">Kotlin视频教程<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://blog.csdn.net/u014803701/article/details/83652187" target="_blank" rel="noopener noreferrer">Android框架、APP汇总<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.liaoxuefeng.com/wiki/896043488029600" target="_blank" rel="noopener noreferrer">廖雪峰的git教程<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://help.github.com/en" target="_blank" rel="noopener noreferrer">github帮助<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://material.io/design/" target="_blank" rel="noopener noreferrer">material design<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.zcool.com.cn/article/ZNzg1Mjg4.html" target="_blank" rel="noopener noreferrer">2019ui设计趋势<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/training/basics/intents/" target="_blank" rel="noopener noreferrer">Activity与其他应用交互<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/components/intents-filters" target="_blank" rel="noopener noreferrer">Intent 和 Intent 过滤器<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/topics/permissions/overview" target="_blank" rel="noopener noreferrer">android权限概念<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://github.com/MyLifeMyTravel/AndroidCore/tree/master/switchlanguage" target="_blank" rel="noopener noreferrer">Android App多语言手动切换<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.cnblogs.com/changyiqiang/p/6044618.html" target="_blank" rel="noopener noreferrer">MVP模式<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://blog.csdn.net/xiaoyu940601/article/details/56483383/" target="_blank" rel="noopener noreferrer">MVVM模式<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/6872b699879d" target="_blank" rel="noopener noreferrer">MVVM框架robobinding<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://yq.aliyun.com/articles/465914" target="_blank" rel="noopener noreferrer">robobinding框架入门<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/topics/data/data-storage" target="_blank" rel="noopener noreferrer">数据和文件存储概览<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/9c53d3c518fa" target="_blank" rel="noopener noreferrer">SQLite数据库开发实例<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://blog.csdn.net/chen185597989/article/details/70650034" target="_blank" rel="noopener noreferrer">ListView与SQLite<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://blog.csdn.net/iispring/article/details/50793455/" target="_blank" rel="noopener noreferrer">Adapter使用详解<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="http://www.360doc.com/content/16/0808/14/9200790_581676933.shtml" target="_blank" rel="noopener noreferrer">RecyclerView和ListView对比分析<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.bmob.cn/" target="_blank" rel="noopener noreferrer">Bmob后端云<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.imooc.com/article/49952" target="_blank" rel="noopener noreferrer">Room ORM 数据库框架<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/8035eb5da7a2" target="_blank" rel="noopener noreferrer">第三方数据库框架 - LitePal简介<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/components/services.html" target="_blank" rel="noopener noreferrer">服务概览与扩展 IntentService 类<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.cnblogs.com/feidu/p/8074268.html" target="_blank" rel="noopener noreferrer">IntentService使用和源码分析<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/components/bound-services" target="_blank" rel="noopener noreferrer">绑定服务<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.cnblogs.com/findumars/p/6590514.html" target="_blank" rel="noopener noreferrer">简单音乐播放器实现<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/components/processes-and-threads" target="_blank" rel="noopener noreferrer">进程与线程概览<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/topics/providers/content-providers" target="_blank" rel="noopener noreferrer">内容提供程序<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.cnblogs.com/lyd447113735/p/7805878.html" target="_blank" rel="noopener noreferrer">常用URI<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/training/basics/network-ops/index.html" target="_blank" rel="noopener noreferrer">执行网络操作<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/reference/android/os/AsyncTask" target="_blank" rel="noopener noreferrer">异步任务<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/f9ae5691e1bb" target="_blank" rel="noopener noreferrer">eventbus使用<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://developer.android.google.cn/guide/webapps/webview#UsingJavaScript" target="_blank" rel="noopener noreferrer">用WebView构建Web app<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/d3aa8b80d87c" target="_blank" rel="noopener noreferrer">Android应用内启动相机拍照并获取照片的两种方式<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.jianshu.com/p/bc38d6a15809" target="_blank" rel="noopener noreferrer">AppTheme属性设置集合<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://blog.csdn.net/qq_26554909/article/details/82085666" target="_blank" rel="noopener noreferrer">Activity与Fragment的相互跳转<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="数据传递"><a href="#数据传递" class="header-anchor">#</a> 数据传递</h2> <h3 id="使用意图传递"><a href="#使用意图传递" class="header-anchor">#</a> 使用意图传递</h3> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Intent</span> intent <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Intent</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> <span class="token class-name">Activity</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// this继承了context类</span>
intent<span class="token punctuation">.</span><span class="token function">putExtra</span><span class="token punctuation">(</span><span class="token string">&quot;msg&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;some msg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//设置要发送的数据</span>
<span class="token function">startActivity</span><span class="token punctuation">(</span>intent<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 获取数据</span>
<span class="token class-name">Intent</span> intent <span class="token operator">=</span> <span class="token function">getIntent</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">String</span> data <span class="token operator">=</span> intent<span class="token punctuation">.</span><span class="token function">getStringExtra</span><span class="token punctuation">(</span><span class="token string">&quot;msg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//msg对应putExtra的msg</span>
</code></pre></div><h2 id="从系统选择文本文件"><a href="#从系统选择文本文件" class="header-anchor">#</a> 从系统选择文本文件</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> TXT_CODE<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token function">onClick</span><span class="token punctuation">(</span><span class="token class-name">View</span> v<span class="token punctuation">)</span> <span class="token punctuation">{</span> 
	<span class="token comment">//构建一个内容选择的Intent</span>
    <span class="token class-name">Intent</span> intent <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Intent</span><span class="token punctuation">(</span><span class="token class-name">Intent</span><span class="token punctuation">.</span>ACTION_GET_CONTENT<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//设置选择类型为txt类型</span>
    intent<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    intent<span class="token punctuation">.</span><span class="token function">addCategory</span><span class="token punctuation">(</span><span class="token class-name">Intent</span><span class="token punctuation">.</span>CATEGORY_OPENABLE<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 打开文本选择</span>
    <span class="token function">startActivityForResult</span><span class="token punctuation">(</span>intent<span class="token punctuation">,</span> TXT_CODE<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

 <span class="token keyword">protected</span> <span class="token keyword">void</span> <span class="token function">onActivityResult</span><span class="token punctuation">(</span><span class="token keyword">int</span> requestCode<span class="token punctuation">,</span> <span class="token keyword">int</span> resultCode<span class="token punctuation">,</span> <span class="token class-name">Intent</span> data<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>resultCode <span class="token operator">==</span> <span class="token class-name">Activity</span><span class="token punctuation">.</span>RESULT_OK<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>requestCode <span class="token operator">==</span> TXT_CODE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token class-name">Uri</span> uri <span class="token operator">=</span> data<span class="token punctuation">.</span><span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
               
                <span class="token class-name">Toast</span><span class="token punctuation">.</span><span class="token function">makeText</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> <span class="token string">&quot;文件路径：&quot;</span><span class="token operator">+</span>uri<span class="token punctuation">.</span><span class="token function">getPath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">Toast</span><span class="token punctuation">.</span>LENGTH_SHORT<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
</code></pre></div><h2 id="常用文件后缀对应的mime类型"><a href="#常用文件后缀对应的mime类型" class="header-anchor">#</a> 常用文件后缀对应的MIME类型</h2> <div class="language-yaml extra-class"><pre class="language-yaml"><code>//<span class="token punctuation">{</span>后缀名，MIME类型<span class="token punctuation">}</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.3gp&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/3gpp&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.apk&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.android.package-archive&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.asf&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/x-ms-asf&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.avi&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/x-msvideo&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.bin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/octet-stream&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.bmp&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;image/bmp&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.c&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.class&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/octet-stream&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.conf&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.cpp&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.doc&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/msword&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.docx&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.openxmlformats-officedocument.wordprocessingml.document&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span><span class="token string">&quot;.xls&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.ms-excel&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.xlsx&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.exe&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/octet-stream&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.gif&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;image/gif&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.gtar&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-gtar&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.gz&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-gzip&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.h&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.htm&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/html&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.html&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/html&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.jar&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/java-archive&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.java&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.jpeg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;image/jpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.jpg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;image/jpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.js&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-javascript&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.log&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.m3u&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-mpegurl&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.m4a&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/mp4a-latm&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.m4b&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/mp4a-latm&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.m4p&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/mp4a-latm&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.m4u&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/vnd.mpegurl&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.m4v&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/x-m4v&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mov&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/quicktime&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mp2&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-mpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mp3&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-mpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mp4&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/mp4&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mpc&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.mpohun.certificate&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mpe&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/mpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mpeg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/mpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mpg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/mpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mpg4&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;video/mp4&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.mpga&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/mpeg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.msg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.ms-outlook&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.ogg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/ogg&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.pdf&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/pdf&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.png&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;image/png&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.pps&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.ms-powerpoint&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.ppt&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.ms-powerpoint&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.pptx&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.openxmlformats-officedocument.presentationml.presentation&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span><span class="token string">&quot;.prop&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.rc&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.rmvb&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-pn-realaudio&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.rtf&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/rtf&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.sh&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.tar&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-tar&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.tgz&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-compressed&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.txt&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.wav&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-wav&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.wma&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-ms-wma&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.wmv&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;audio/x-ms-wmv&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.wps&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/vnd.ms-works&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.xml&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.z&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-compress&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;.zip&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;application/x-zip-compressed&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> 
<span class="token punctuation">{</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;*/*&quot;</span><span class="token punctuation">}</span> 
<span class="token punctuation">}</span>; 
</code></pre></div><h2 id="解析uri-读取文本文件"><a href="#解析uri-读取文本文件" class="header-anchor">#</a> 解析uri，读取文本文件</h2> <div class="language-java extra-class"><pre class="language-java"><code>
  <span class="token comment">//Uri ----&gt; InputStream</span>
            is <span class="token operator">=</span> <span class="token function">getContentResolver</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">openInputStream</span><span class="token punctuation">(</span>uri<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><h2 id="handler事件分发"><a href="#handler事件分发" class="header-anchor">#</a> handler事件分发</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Handler</span> handler <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Handler</span><span class="token punctuation">(</span><span class="token class-name">Looper</span><span class="token punctuation">.</span><span class="token function">getMainLooper</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
handler<span class="token punctuation">.</span><span class="token function">postDelayed</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Runnable</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token annotation punctuation">@override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">//todo: 要执行的代码</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

</code></pre></div><h2 id="文件存储的默认位置"><a href="#文件存储的默认位置" class="header-anchor">#</a> 文件存储的默认位置</h2> <p><code>data/data/&lt;packagename&gt;/files/</code></p> <h2 id="文件读写模式"><a href="#文件读写模式" class="header-anchor">#</a> 文件读写模式</h2> <p><code>MODE_PRIVATE</code></p> <p><code>MODE_APPEND</code></p> <p><code>MODE_WORLD_READABLE</code></p> <p><code>MODE_WORLD_WRITABLE</code></p> <h2 id="文件的读写"><a href="#文件的读写" class="header-anchor">#</a> 文件的读写</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token comment">// write</span>
<span class="token class-name">FileOutputstream</span> fos<span class="token punctuation">;</span>
<span class="token class-name">String</span> filename <span class="token operator">=</span> <span class="token string">&quot;test.txt&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">try</span> <span class="token punctuation">{</span>
	fos <span class="token operator">=</span> <span class="token function">openFileOutput</span><span class="token punctuation">(</span>filename<span class="token punctuation">,</span> MODE_PRIVATE<span class="token punctuation">)</span><span class="token punctuation">;</span>
	fos<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span><span class="token string">&quot;******&quot;</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fos<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span> <span class="token keyword">catch</span><span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">/************************/</span>

<span class="token comment">// read</span>
<span class="token class-name">FileInputStream</span> fis<span class="token punctuation">;</span>
<span class="token class-name">String</span> filename <span class="token operator">=</span> <span class="token string">&quot;test.txt&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">try</span> <span class="token punctuation">{</span>
    fis <span class="token operator">=</span> <span class="token function">openFileInput</span><span class="token punctuation">(</span>filename<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 使用byte数组接收输入</span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> buf <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>fis<span class="token punctuation">.</span><span class="token function">available</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    fis<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>buf<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 还原成字符串</span>
    <span class="token class-name">String</span> content <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span>buf<span class="token punctuation">)</span><span class="token punctuation">;</span>
    
<span class="token punctuation">}</span>
</code></pre></div><h2 id="外部存储的读写"><a href="#外部存储的读写" class="header-anchor">#</a> 外部存储的读写</h2> <p>在 <code>manifest.xml</code>中添加权限声明</p> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>uses-permission</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.permission.WRITE_EXTERNAL_STORAGE<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>uses-permission</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.permission.READ_EXTERNAL_STORAGE<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
</code></pre></div><p>读写文件的代码</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token comment">// 读写前检测外部设备的状态</span>
<span class="token class-name">String</span> state <span class="token operator">=</span> <span class="token class-name">Environment</span><span class="token punctuation">.</span><span class="token function">getExternalStorageState</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 外部设备已挂载</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>state<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token class-name">Environment</span><span class="token punctuation">.</span>MEDIA_MOUNTED<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token class-name">File</span> <span class="token class-name">SDPath</span> <span class="token operator">=</span> <span class="token class-name">Environment</span><span class="token punctuation">.</span><span class="token function">getExternalStorageDirectory</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 获取外部设备目录</span>
    <span class="token class-name">File</span> file <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span><span class="token class-name">SDPath</span><span class="token punctuation">,</span> <span class="token string">&quot;data.txt&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">FileOutputStream</span> <span class="token operator">=</span> fos<span class="token punctuation">;</span>
    <span class="token keyword">try</span><span class="token punctuation">{</span>
        fos <span class="token operator">=</span> <span class="token class-name">FileOutputStream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">;</span>
        fos<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span><span class="token string">&quot;NMSL&quot;</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span><span class="token keyword">catch</span><span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token keyword">finally</span> <span class="token punctuation">{</span>
                fos<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">/**********************************/</span>

<span class="token class-name">String</span> state <span class="token operator">=</span> <span class="token class-name">Environment</span><span class="token punctuation">.</span><span class="token function">getExternalStorageState</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>state<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token class-name">Environment</span><span class="token punctuation">.</span>MEDIA_MOUNTED<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token class-name">File</span> <span class="token class-name">SDPath</span> <span class="token operator">=</span> <span class="token class-name">Environment</span><span class="token punctuation">.</span><span class="token function">getExternalStorageDirectory</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">File</span> file <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span><span class="token class-name">SDPath</span><span class="token punctuation">,</span> <span class="token string">&quot;data.txt&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">FileInputStream</span> fis<span class="token punctuation">;</span>
    <span class="token keyword">try</span><span class="token punctuation">{</span>
        fis <span class="token operator">=</span> <span class="token function">openFileInputStream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">BufferedReader</span> br <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BufferedReader</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">InputStreamReader</span><span class="token punctuation">(</span>fis<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> data <span class="token operator">=</span> br<span class="token punctuation">.</span><span class="token function">getLine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">Exception</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="获取输入框的内容并检查"><a href="#获取输入框的内容并检查" class="header-anchor">#</a> 获取输入框的内容并检查</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">EditText</span> et <span class="token operator">=</span>  <span class="token punctuation">(</span><span class="token class-name">EditText</span><span class="token punctuation">)</span><span class="token function">findViewById</span><span class="token punctuation">(</span><span class="token class-name">R</span><span class="token punctuation">.</span>id<span class="token punctuation">.</span>et_msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">String</span> msg <span class="token operator">=</span> et<span class="token punctuation">.</span><span class="token function">getText</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">TextUtils</span><span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span>msg<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// if msg is empty</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
    <span class="token comment">// todo:check the msg</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="pull解析xml文件"><a href="#pull解析xml文件" class="header-anchor">#</a> PULL解析XML文件</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>xmlpull<span class="token punctuation">.</span>v1<span class="token punctuation">.</span></span><span class="token class-name">XmlPullParser</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">android<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Xml</span><span class="token punctuation">;</span>
<span class="token class-name">Inpustream</span> is <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileInputStream</span><span class="token punctuation">(</span><span class="token string">&quot;data.xml&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">XmlPullParser</span> parser <span class="token operator">=</span> <span class="token class-name">Xml</span><span class="token punctuation">.</span><span class="token function">newPullParser</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
parser<span class="token punctuation">.</span><span class="token function">setInput</span><span class="token punctuation">(</span>is<span class="token punctuation">,</span><span class="token string">&quot;utf-8&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 获取当前事件的类型</span>
<span class="token keyword">int</span> type <span class="token operator">=</span> parser<span class="token punctuation">.</span><span class="token function">getEventType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">while</span> <span class="token punctuation">(</span>type <span class="token operator">!=</span> <span class="token class-name">XmlPUllParser</span><span class="token punctuation">.</span>END_DOCUMENT<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">switch</span><span class="token punctuation">(</span>type<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">case</span> <span class="token class-name">XmlPullParser</span><span class="token punctuation">.</span>START_TAG<span class="token operator">:</span>
            <span class="token comment">// 根节点</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token string">&quot;xxx&quot;</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>parser<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">//todo</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token class-name">XmlPullParser</span><span class="token punctuation">.</span>END_TAG<span class="token operator">:</span>
            <span class="token comment">// 遇到结束标签</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token string">&quot;xxxxx&quot;</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>parser<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">//todo</span>
            <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    type <span class="token operator">=</span> parser<span class="token punctuation">.</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="gson库解析json文件"><a href="#gson库解析json文件" class="header-anchor">#</a> Gson库解析json文件</h2> <p>json文件放在  <code>res/raw</code> 目录下。</p> <p>获取json文件的输入流</p> <p><code>InputStream is = this.getResources().openRawResource(R.raw.jsonfile)</code></p> <p>定义json数据对应的实体类，属性应与json数据的key保持一致</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Gson</span> gson <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Gson</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">Entity</span> entity <span class="token operator">=</span> gson<span class="token punctuation">.</span><span class="token function">fromJson</span><span class="token punctuation">(</span>json1<span class="token punctuation">,</span> <span class="token class-name">Entity</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">/****************/</span>
<span class="token comment">// 解析json数组</span>
<span class="token class-name">Gson</span> gson <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Gson</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">Type</span> listType <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">TypeToken</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token class-name">Entity</span><span class="token punctuation">&gt;</span> <span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">.</span><span class="token function">getType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Entity</span><span class="token punctuation">&gt;</span></span> nums <span class="token operator">=</span> gson<span class="token punctuation">.</span><span class="token function">fromJson</span><span class="token punctuation">(</span>json2<span class="token punctuation">.</span>listType<span class="token punctuation">)</span><span class="token punctuation">;</span>


</code></pre></div><h2 id="sharedpreferences的使用"><a href="#sharedpreferences的使用" class="header-anchor">#</a> SharedPreferences的使用</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">SharedPreferences</span> sp <span class="token operator">=</span> <span class="token function">getSharedPreferences</span><span class="token punctuation">(</span><span class="token string">&quot;data&quot;</span><span class="token punctuation">,</span><span class="token class-name">Context</span><span class="token punctuation">.</span>MODE_PRIVATE<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 增,改</span>
<span class="token class-name">SharedPreferences<span class="token punctuation">.</span>Editor</span> editor <span class="token operator">=</span> sp<span class="token punctuation">.</span><span class="token function">edit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
editor<span class="token punctuation">.</span><span class="token function">putString</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;msg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
editor<span class="token punctuation">.</span><span class="token function">putInt</span><span class="token punctuation">(</span><span class="token string">&quot;num&quot;</span><span class="token punctuation">,</span><span class="token number">2333</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
editor<span class="token punctuation">.</span><span class="token function">commit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 删</span>
editor<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 删除name字段的数据</span>
editor<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 删除所有数据</span>
<span class="token comment">// 查</span>
<span class="token class-name">String</span> data <span class="token operator">=</span> sp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><h2 id="创建sqlite数据库帮助类"><a href="#创建sqlite数据库帮助类" class="header-anchor">#</a> 创建SQLite数据库帮助类</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token comment">// 此类为适应项目要求要改很多东西，代码较为底层，复用效率低</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">DBHelper</span> extendss <span class="token class-name">SQLiteOpenHelper</span> <span class="token punctuation">{</span>
    <span class="token keyword">public</span> <span class="token class-name">DBHelper</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">super</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> <span class="token string">&quot;data.db&quot;</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">// 数据库第一次被创建时调用该方法</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onCreate</span><span class="token punctuation">(</span><span class="token class-name">SQLiteDatabase</span> db<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 初始化数据库的表结构，执行一条建表的SQL语句</span>
        <span class="token keyword">final</span> <span class="token class-name">String</span> sql <span class="token operator">=</span> <span class="token string">&quot;CREATE TABLE tablename (_id PRIMARY KEY AUTOINCREMENT, name VARCHAR(20), price INTEGER)&quot;</span><span class="token punctuation">;</span>
        db<span class="token punctuation">.</span><span class="token function">execSQL</span><span class="token punctuation">(</span>sql<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">// 当数据库的版本号增加是调用</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onUpgrade</span><span class="token punctuation">(</span><span class="token class-name">SQLiteDatabase</span> db<span class="token punctuation">,</span> <span class="token keyword">int</span> oldVersion<span class="token punctuation">,</span> <span class="token keyword">int</span> newVersion<span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
    
    <span class="token comment">// 增</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">insert</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> price<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">SQLiteDatabase</span> db <span class="token operator">=</span> <span class="token function">getWritableDatabase</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ContentValues</span> values <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ContentValues</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        values<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">,</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>
        values<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;price&quot;</span><span class="token punctuation">,</span>price<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">long</span> id  db<span class="token punctuation">.</span><span class="token function">insert</span><span class="token punctuation">(</span><span class="token string">&quot;tablename&quot;</span><span class="token punctuation">,</span><span class="token keyword">null</span><span class="token punctuation">,</span> values<span class="token punctuation">)</span><span class="token punctuation">;</span>
        db<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">// 查</span>
    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">update</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">SQLiteDatabase</span> db <span class="token operator">=</span> helper<span class="token punctuation">.</span><span class="token function">getWritableDatabase</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        
    <span class="token punctuation">}</span>
    
    <span class="token comment">// 删</span>
    <span class="token keyword">public</span> <span class="token keyword">int</span>  <span class="token function">delete</span><span class="token punctuation">(</span><span class="token keyword">long</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">SQLiteDatabase</span> db <span class="token operator">=</span> <span class="token function">getWritableDatabase</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> number <span class="token operator">=</span> db<span class="token punctuation">.</span><span class="token function">delete</span><span class="token punctuation">(</span><span class="token string">&quot;tablename&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;_id=?&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span>id<span class="token operator">+</span><span class="token string">&quot;&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        db<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> number<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="配置butterknife10-2-0"><a href="#配置butterknife10-2-0" class="header-anchor">#</a> 配置ButterKnife10.2.0</h2> <h3 id="app-build-gradle"><a href="#app-build-gradle" class="header-anchor">#</a> app build.gradle</h3> <div class="language-groovy extra-class"><pre class="language-groovy"><code>apply plugin<span class="token punctuation">:</span> <span class="token string">'com.jakewharton.butterknife'</span>
android<span class="token punctuation">{</span>
     compileOptions <span class="token punctuation">{</span>
        sourceCompatibility JavaVersion<span class="token punctuation">.</span>VERSION_1_8
        targetCompatibility JavaVersion<span class="token punctuation">.</span>VERSION_1_8
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
dependencies <span class="token punctuation">{</span>  
	implementation <span class="token string">'com.jakewharton:butterknife:10.2.0'</span>
	annotationProcessor <span class="token string">'com.jakewharton:butterknife-compiler:10.2.0'</span>
<span class="token punctuation">}</span>
</code></pre></div><h3 id="project-build-gradle"><a href="#project-build-gradle" class="header-anchor">#</a> project build.gradle</h3> <div class="language-groovy extra-class"><pre class="language-groovy"><code> 
buildscript <span class="token punctuation">{</span>
    repositories <span class="token punctuation">{</span>
        <span class="token function">jcenter</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">google</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">mavenCentral</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    dependencies <span class="token punctuation">{</span>
        classpath <span class="token string">'com.jakewharton:butterknife-gradle-plugin:10.2.0'</span>

    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
 
allprojects <span class="token punctuation">{</span>
    repositories <span class="token punctuation">{</span>
        <span class="token function">jcenter</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">google</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">mavenCentral</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
 

</code></pre></div><h2 id="在fragment中使用butterknife"><a href="#在fragment中使用butterknife" class="header-anchor">#</a> 在Fragment中使用ButterKnife</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Unbinder</span> unbinder<span class="token punctuation">;</span>  
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token class-name">View</span> <span class="token function">onCreateView</span><span class="token punctuation">(</span><span class="token class-name">LayoutInflater</span> inflater<span class="token punctuation">,</span> <span class="token class-name">ViewGroup</span> container<span class="token punctuation">,</span>
                         <span class="token class-name">Bundle</span> savedInstanceState<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token class-name">View</span> view <span class="token operator">=</span> inflater<span class="token punctuation">.</span><span class="token function">inflate</span><span class="token punctuation">(</span><span class="token class-name">R</span><span class="token punctuation">.</span>layout<span class="token punctuation">.</span>fragment_main<span class="token punctuation">,</span> container<span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    unbinder <span class="token operator">=</span> <span class="token class-name">ButterKnife</span><span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> view<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> view<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onDetach</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">onDetach</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	unbinder<span class="token punctuation">.</span><span class="token function">unbind</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="在fragment设置监听事件"><a href="#在fragment设置监听事件" class="header-anchor">#</a> 在Fragment设置监听事件</h2> <p>只要 <code>Butterknife</code>的 <code>bind(this,view)</code>成功，在fragment可以直接用注解写函数</p> <div class="language-java extra-class"><pre class="language-java"><code>  <span class="token annotation punctuation">@OnClick</span><span class="token punctuation">(</span><span class="token class-name">R</span><span class="token punctuation">.</span>id<span class="token punctuation">.</span>choose_txt_btn<span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onClick</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Log</span><span class="token punctuation">.</span><span class="token function">e</span><span class="token punctuation">(</span><span class="token function">getClass</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;点击了按钮&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//构建一个内容选择的Intent</span>
        <span class="token class-name">Intent</span> intent <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Intent</span><span class="token punctuation">(</span><span class="token class-name">Intent</span><span class="token punctuation">.</span>ACTION_GET_CONTENT<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//设置选择类型为txt类型</span>
        intent<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token string">&quot;text/plain&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 打开文本选择</span>
        <span class="token function">startActivityForResult</span><span class="token punctuation">(</span>intent<span class="token punctuation">,</span> TXT_CODE<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>


</code></pre></div><h2 id="同一个activity的fragment的跳转"><a href="#同一个activity的fragment的跳转" class="header-anchor">#</a> 同一个Activity的fragment的跳转</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token function">getActivity</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getSupportFragmentManager</span><span class="token punctuation">(</span><span class="token punctuation">)</span> 
    <span class="token punctuation">.</span><span class="token function">beginTransaction</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token class-name">R</span><span class="token punctuation">.</span>id<span class="token punctuation">.</span>xx<span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">XxxFragment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">)</span> 
    <span class="token punctuation">.</span><span class="token function">addToBackStack</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">commit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><p>R.id.xx：Fragment对应的Activity布局中FragmentLayout的id
new XxxFragment()：要跳转到的Fragment
addToBackStack(null)：可以省略不写（不写表示为非压栈式添加）</p> <h2 id="在fragment中获取跳转的activity返回的结果"><a href="#在fragment中获取跳转的activity返回的结果" class="header-anchor">#</a> 在fragment中获取跳转的activity返回的结果</h2> <div class="language-java extra-class"><pre class="language-java"><code> <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onActivityResult</span><span class="token punctuation">(</span><span class="token keyword">int</span> requestCode<span class="token punctuation">,</span> <span class="token keyword">int</span> resultCode<span class="token punctuation">,</span> <span class="token class-name">Intent</span> data<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>resultCode <span class="token operator">==</span> <span class="token class-name">Activity</span><span class="token punctuation">.</span>RESULT_OK<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>requestCode <span class="token operator">==</span> <span class="token class-name">MainActivityFragment</span><span class="token punctuation">.</span>TXT_CODE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token class-name">Uri</span> uri <span class="token operator">=</span> data<span class="token punctuation">.</span><span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token class-name">Toast</span><span class="token punctuation">.</span><span class="token function">makeText</span><span class="token punctuation">(</span><span class="token function">getContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> uri<span class="token punctuation">.</span><span class="token function">getPath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">Toast</span><span class="token punctuation">.</span>LENGTH_SHORT<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>


        <span class="token punctuation">}</span>

    <span class="token punctuation">}</span>
</code></pre></div><h2 id="再按一次退出程序"><a href="#再按一次退出程序" class="header-anchor">#</a> 再按一次退出程序</h2> <div class="language-java extra-class"><pre class="language-java"><code> <span class="token comment">//声明一个long类型变量：用于存放上一点击“返回键”的时刻</span>
  <span class="token keyword">private</span> <span class="token keyword">long</span> mExitTime<span class="token punctuation">;</span>
  <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">onKeyDown</span><span class="token punctuation">(</span><span class="token keyword">int</span> keyCode<span class="token punctuation">,</span> <span class="token class-name">KeyEvent</span> event<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">//判断用户是否点击了“返回键”</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>keyCode <span class="token operator">==</span> <span class="token class-name">KeyEvent</span><span class="token punctuation">.</span>KEYCODE_BACK<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">//与上次点击返回键时刻作差</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">currentTimeMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> mExitTime<span class="token punctuation">)</span> <span class="token operator">&gt;</span> <span class="token number">2000</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token comment">//大于2000ms则认为是误操作，使用Toast进行提示</span>
                <span class="token class-name">Toast</span><span class="token punctuation">.</span><span class="token function">makeText</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> <span class="token string">&quot;再按一次退出程序&quot;</span><span class="token punctuation">,</span> <span class="token class-name">Toast</span><span class="token punctuation">.</span>LENGTH_SHORT<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">//并记录下本次点击“返回键”的时刻，以便下次进行判断</span>
                mExitTime <span class="token operator">=</span> <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">currentTimeMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                    <span class="token comment">//小于2000ms则认为是用户确实希望退出程序-调用System.exit()方法进行退出</span>
                <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">exit</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
     <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">onKeyDown</span><span class="token punctuation">(</span>keyCode<span class="token punctuation">,</span> event<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
</code></pre></div><h2 id="权限的动态申请"><a href="#权限的动态申请" class="header-anchor">#</a> 权限的动态申请</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">initView</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token comment">//先判断有无权限，如果没有，则进行权限的申请</span>
<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">checkPermission</span><span class="token punctuation">(</span><span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>INTERNET<span class="token punctuation">,</span>
<span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>RECEIVE_BOOT_COMPLETED<span class="token punctuation">,</span>
<span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>READ_EXTERNAL_STORAGE<span class="token punctuation">,</span>
                <span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>WRITE_EXTERNAL_STORAGE<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span><span class="token comment">//若没有权限，则进行申请requestPermission(Manifest.permission.INTERNET,</span>
        <span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>RECEIVE_BOOT_COMPLETED<span class="token punctuation">,</span>
        <span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>READ_EXTERNAL_STORAGE<span class="token punctuation">,</span>
        <span class="token class-name">Manifest</span><span class="token punctuation">.</span>permission<span class="token punctuation">.</span>WRITE_EXTERNAL_STORAGE<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">checkPermission</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> permissions<span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token comment">//判断是否拥有权限</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">String</span> permission<span class="token operator">:</span>permissions<span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token class-name">ContextCompat</span><span class="token punctuation">.</span><span class="token function">checkSelfPermission</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span>permission<span class="token punctuation">)</span><span class="token operator">!=</span><span class="token class-name">PackageManager</span><span class="token punctuation">.</span>PERMISSION_GRANTED<span class="token punctuation">)</span><span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

 <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">requestPermission</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> permissions<span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token comment">//请求权限，后面的int值是请求权限的数量</span>
        <span class="token class-name">ActivityCompat</span><span class="token punctuation">.</span><span class="token function">requestPermissions</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span>permissions<span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

</code></pre></div><h2 id="常用权限"><a href="#常用权限" class="header-anchor">#</a> 常用权限</h2> <p>android.permission.INTERNET
最常用的权限之一：网络权限，允许程序打开网络套接字(Allows applications to open network sockets)</p> <p>android.permission.ACCESS_WIFI_STATE
允许程序访问Wi-Fi网络状态信息(Allows applications to access information about Wi-Fi networks)</p> <p>android.permission.BATTERY_STATS
允许程序更新手机电池统计信息(Allows an application to update the collected battery statistics)</p> <p>android.permission.ACCESS_NETWORK_STATE
允许程序访问有关GSM网络信息(Allows applications to access information about networks)</p> <p>android.permission.ACCESS_CHECKIN_PROPERTIES
允许读写访问”properties”表在checkin数据库中，改值可以修改上传( Allows read/write access to the “properties” table in the checkin database, to change values that get uploaded)
android.permission.ACCESS_COARSE_LOCATION
允许一个程序访问CellID或WiFi热点来获取粗略的位置(Allows an application to access coarse (e.g., Cell-ID, WiFi) location)
android.permission.ACCESS_FINE_LOCATION
允许一个程序访问精确位置(如GPS) (Allows an application to access fine (e.g., GPS) location)
android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
允许应用程序访问额外的位置提供命令(Allows an application to access extra location provider commands)
android.permission.ACCESS_MOCK_LOCATION
允许程序创建模拟位置提供用于测试(Allows an application to create mock location providers for testing)
android.permission.ACCESS_SURFACE_FLINGER
允许程序使用SurfaceFlinger底层特性(Allows an application to use SurfaceFlinger’s low level features)
android.permission.ADD_SYSTEM_SERVICE
允许程序发布系统级服务(Allows an application to publish system-level services).
android.permission.BLUETOOTH
允许程序连接到已配对的蓝牙设备(Allows applications to connect to paired bluetooth devices)
android.permission.BLUETOOTH_ADMIN
允许程序发现和配对蓝牙设备(Allows applications to discover and pair bluetooth devices)
android.permission.BROADCAST_STICKY
允许一个程序广播常用intents(Allows an application to broadcast sticky intents)
android.permission.BROADCAST_PACKAGE_REMOVED
允许程序广播一个提示消息在一个应用程序包已经移除后(Allows an application to broadcast a notification that an application
package has been removed)</p> <p>android.permission.CHANGE_NETWORK_STATE
允许程序改变网络连接状态(Allows applications to change network connectivity state)
android.permission.CHANGE_WIFI_STATE
允许程序改变Wi-Fi连接状态(Allows applications to change Wi-Fi connectivity state)</p> <p>android.permission.CALL_PHONE
允许一个程序电话拨号不需通过拨号用户界面需要用户确认(Allows an application to initiate a phone call without going through the Dialer user interface for the user to confirm the call being placed.)
android.permission.CALL_PRIVILEGED
允许一个程序拨打任何号码，包含紧急号码无需通过拨号用户界面需要用户确认(Allows an application to call any phone number, including emergency numbers, without going through the Dialer user interface for the user to confirm the call being placed)
android.permission.CAMERA
请求访问使用照相设备(Required to be able to access the camera device. )
android.permission.CHANGE_CONFIGURATION
允许一个程序修改当前设置，如本地化(Allows an application to modify the current configuration, such as locale. )
android.permission.CLEAR_APP_CACHE
允许一个程序清楚缓存从所有安装的程序在设备中(Allows an application to clear the caches of all installed applications on the device. )
android.permission.CLEAR_APP_USER_DATA
允许一个程序清除用户设置(Allows an application to clear user data)
android.permission.CONTROL_LOCATION_UPDATES
允许启用禁止位置更新提示从无线模块(Allows enabling/disabling location update notifications from the radio. )
android.permission.DELETE_CACHE_FILES
允许程序删除缓存文件(Allows an application to delete cache files)
android.permission.DELETE_PACKAGES
允许一个程序删除包(Allows an application to delete packages)
android.permission.DEVICE_POWER
允许访问底层电源管理(Allows low-level access to power management)
android.permission.DISABLE_KEYGUARD
允许程序禁用键盘锁(Allows applications to disable the keyguard )
android.permission.DUMP
允许程序返回状态抓取信息从系统服务(Allows an application to retrieve state dump information from system services.)
android.permission.FACTORY_TEST
作为一个工厂测试程序，运行在root用户(Run as a manufacturer test application, running as the root user. )
android.permission.FLASHLIGHT
访问闪光灯,android开发网提示HTC Dream不包含闪光灯(Allows access to the flashlight )
android.permission.FORCE_BACK
允许程序强行一个后退操作是否在顶层activities(Allows an application to force a BACK operation on whatever is the top activity. )
android.permission.FOTA_UPDATE
暂时不了解这是做什么使用的，android开发网分析可能是一个预留权限.
android.permission.GET_ACCOUNTS
访问一个帐户列表(Allows access to the list of accounts in the Accounts Service)
android.permission.GET_PACKAGE_SIZE
允许一个程序获取任何package占用空间容量(Allows an application to find out the space used by any package. )
android.permission.GET_TASKS
允许一个程序获取信息有关当前或最近运行的任务，一个缩略的任务状态，是否活动等等(Allows an application to get information about the currently or recently running tasks: a thumbnail representation of the tasks, what activities are running in it, etc.)
android.permission.HARDWARE_TEST
允许访问硬件(Allows access to hardware peripherals. )
android.permission.INJECT_EVENTS
允许一个程序截获用户事件如按键、触摸、轨迹球等等到一个时间流，android 开发网提醒算是hook技术吧(Allows an application to inject user events (keys, touch, trackball) into the event stream and deliver them to ANY window.)
android.permission.INSTALL_PACKAGES
允许一个程序安装packages(Allows an application to install packages. )
android.permission.INTERNAL_SYSTEM_WINDOW
允许打开窗口使用系统用户界面(Allows an application to open windows that are for use by parts of the system user interface. )
android.permission.MODIFY_AUDIO_SETTINGS
允许程序修改全局音频设置(Allows an application to modify global audio settings)
android.permission.MODIFY_PHONE_STATE
允许修改话机状态，如电源，人机接口等(Allows modification of the telephony state – power on, mmi, etc. )
android.permission.MOUNT_UNMOUNT_FILESYSTEMS
允许挂载和反挂载文件系统可移动存储(Allows mounting and unmounting file systems for removable storage. )
android.permission.PERSISTENT_ACTIVITY
允许一个程序设置他的activities显示(Allow an application to make its activities persistent. )
android.permission.PROCESS_OUTGOING_CALLS
允许程序监视、修改有关播出电话(Allows an application to monitor, modify, or abort outgoing calls)
android.permission.READ_CALENDAR
允许程序读取用户日历数据(Allows an application to read the user’s calendar data.)
android.permission.READ_CONTACTS
允许程序读取用户联系人数据(Allows an application to read the user’s contacts data.)
android.permission.READ_FRAME_BUFFER
允许程序屏幕波或和更多常规的访问帧缓冲数据(Allows an application to take screen shots and more generally get access to the frame buffer data)
android.permission.READ_INPUT_STATE
允许程序返回当前按键状态(Allows an application to retrieve the current state of keys and switches. )
android.permission.READ_LOGS
允许程序读取底层系统日志文件(Allows an application to read the low-level system log files. )
android.permission.READ_OWNER_DATA
允许程序读取所有者数据(Allows an application to read the owner’s data)
android.permission.READ_SMS
允许程序读取短信息(Allows an application to read SMS messages.)
android.permission.READ_SYNC_SETTINGS
允许程序读取同步设置(Allows applications to read the sync settings)
android.permission.READ_SYNC_STATS
允许程序读取同步状态(Allows applications to read the sync stats)
android.permission.REBOOT
请求能够重新启动设备(Required to be able to reboot the device. )
android.permission.RECEIVE_BOOT_COMPLETED
允许一个程序接收到 ACTION_BOOT_COMPLETED广播在系统完成启动(Allows an application to receive the ACTION_BOOT_COMPLETED that is broadcast after the system finishes booting. )
android.permission.RECEIVE_MMS
允许一个程序监控将收到MMS彩信,记录或处理(Allows an application to monitor incoming MMS messages, to record or perform processing on them. )
android.permission.RECEIVE_SMS
允许程序监控一个将收到短信息，记录或处理(Allows an application to monitor incoming SMS messages, to record or perform processing on them.)
android.permission.RECEIVE_WAP_PUSH
允许程序监控将收到WAP PUSH信息(Allows an application to monitor incoming WAP push messages. )
android.permission.RECORD_AUDIO
允许程序录制音频(Allows an application to record audio)
android.permission.RESTART_PACKAGES
允许程序重新启动其他程序(Allows an application to restart other applications)
android.permission.SEND_SMS
允许程序发送SMS短信(Allows an application to send SMS messages)
android.permission.SET_ACTIVITY_WATCHER
允许程序监控或控制activities已经启动全局系统中(Allows an application to watch and control how activities are started globally in the system.)
android.permission.SET_ALWAYS_FINISH
允许程序控制是否活动间接完成在处于后台时(Allows an application to control whether activities are immediately finished when put in the background.)
android.permission.SET_ANIMATION_SCALE
修改全局信息比例(Modify the global animation scaling factor.)
android.permission.SET_DEBUG_APP
配置一个程序用于调试(Configure an application for debugging.)
android.permission.SET_ORIENTATION
允许底层访问设置屏幕方向和实际旋转(Allows low-level access to setting the orientation (actually rotation) of the screen.)
android.permission.SET_PROCESS_FOREGROUND
允许程序当前运行程序强行到前台(Allows an application to force any currently running process to be in the foreground.)
android.permission.SET_PROCESS_LIMIT
允许设置最大的运行进程数量(Allows an application to set the maximum number of (not needed) application processes that can be running. )
android.permission.SET_TIME_ZONE
允许程序设置时间区域(Allows applications to set the system time zone)
android.permission.SET_WALLPAPER
允许程序设置壁纸(Allows applications to set the wallpaper )
android.permission.SET_WALLPAPER_HINTS
允许程序设置壁纸hits(Allows applications to set the wallpaper hints)
android.permission.SIGNAL_PERSISTENT_PROCESSES
允许程序请求发送信号到所有显示的进程中(Allow an application to request that a signal be sent to all persistent processes)
android.permission.STATUS_BAR
允许程序打开、关闭或禁用状态栏及图标Allows an application to open, close, or disable the status bar and its icons.
android.permission.SUBSCRIBED_FEEDS_READ
允许一个程序访问订阅RSS Feed内容提供(Allows an application to allow access the subscribed feeds ContentProvider. )
android.permission.SUBSCRIBED_FEEDS_WRITE
系统暂时保留改设置,android开发网认为未来版本会加入该功能。
android.permission.SYSTEM_ALERT_WINDOW
允许一个程序打开窗口使用 TYPE_SYSTEM_ALERT，显示在其他所有程序的顶层(Allows an application to open windows using the type TYPE_SYSTEM_ALERT, shown on top of all other applications. )
android.permission.VIBRATE
允许访问振动设备(Allows access to the vibrator)
android.permission.WAKE_LOCK
允许使用PowerManager的 WakeLocks保持进程在休眠时从屏幕消失( Allows using PowerManager WakeLocks to keep processor from sleeping or screen from dimming)
android.permission.WRITE_APN_SETTINGS
允许程序写入API设置(Allows applications to write the apn settings)
android.permission.WRITE_CALENDAR
允许一个程序写入但不读取用户日历数据(Allows an application to write (but not read) the user’s calendar data. )
android.permission.WRITE_CONTACTS
允许程序写入但不读取用户联系人数据(Allows an application to write (but not read) the user’s contacts data. )
android.permission.WRITE_GSERVICES
允许程序修改Google服务地图(Allows an application to modify the Google service map. )
android.permission.WRITE_OWNER_DATA
允许一个程序写入但不读取所有者数据(Allows an application to write (but not read) the owner’s data.)
android.permission.WRITE_SETTINGS
允许程序读取或写入系统设置(Allows an application to read or write the system settings. )
android.permission.WRITE_SMS
允许程序写短信(Allows an application to write SMS messages)
android.permission.WRITE_SYNC_SETTINGS
允许程序写入同步设置(Allows applications to write the sync settings)</p> <h2 id="加载svg资源"><a href="#加载svg资源" class="header-anchor">#</a> 加载svg资源</h2> <p>使用 <code>Vector Asset</code>将svg文件转成android可使用的xml文件</p> <p>![1576735597641](./android 实战/1576735597641.png)</p> <p>Clip Art有android内置的一些经典图标，可以重新设置其大小，颜色，透明度而变成新的图片资源，生成的资源在 <code>drawable</code> 目录</p> <p>![1576735726858](./android 实战/1576735726858.png)</p> <h2 id="设置app图标"><a href="#设置app图标" class="header-anchor">#</a> 设置App图标</h2> <p>使用 <code>Image Asset</code>产生图标</p> <p>![1576735525800](./android 实战/1576735525800.png)</p> <p>图标资源放在 <code>mipmap</code>文件夹</p> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token comment">&lt;!-- manifest.xml --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>manifest</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/apk/res/android<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">package</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.example.ireading<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- 将应用图标设置成ic_laucher_round--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>application</span>
        <span class="token attr-name"><span class="token namespace">android:</span>allowBackup</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>icon</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@mipmap/ic_launcher_round<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>label</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@string/app_name<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>roundIcon</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@mipmap/ic_launcher_round<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>supportsRtl</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>theme</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@style/AppTheme<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>application</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>manifest</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h2 id="recyclerview使用"><a href="#recyclerview使用" class="header-anchor">#</a> RecyclerView使用</h2> <ol><li>添加依赖</li> <li>在界面xml文件声明RecylcerView，创建recyclerview的item的布局</li> <li>自定义适配器类(继承<code>RecyclerView.Adapter</code>类）及其静态内部类的视图帮助类（继承RecyclerView.ViewHolder）</li></ol> <div class="language-java extra-class"><pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyAdapter</span> <span class="token keyword">extends</span> <span class="token class-name">RecyclerView<span class="token punctuation">.</span>Adapter</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">MyAdapter<span class="token punctuation">.</span>MyViewHolder</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>
    <span class="token comment">// MyViewHolder类是MyAdapter类的静态内部类</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">class</span> <span class="token class-name">MyViewHolder</span> <span class="token keyword">extends</span> <span class="token class-name">RecyclerView<span class="token punctuation">.</span>ViewHolder</span> <span class="token punctuation">{</span>
        <span class="token keyword">public</span> <span class="token class-name">TextView</span> textView<span class="token punctuation">;</span>
        <span class="token keyword">public</span> <span class="token class-name">MyViewHolder</span><span class="token punctuation">(</span><span class="token class-name">TextView</span> v<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">super</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span><span class="token punctuation">;</span>
            textView <span class="token operator">=</span> v<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">private</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> mDataset<span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token class-name">MyAdapter</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> myDataset<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        mDataset <span class="token operator">=</span> myDataset<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">MyAdapter<span class="token punctuation">.</span>MyViewHolder</span> <span class="token function">onCreateViewHolder</span><span class="token punctuation">(</span><span class="token class-name">ViewGroup</span> parent<span class="token punctuation">,</span>
                                                   <span class="token keyword">int</span> viewType<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 创建一个item的实例</span>
        <span class="token class-name">TextView</span> v <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token class-name">TextView</span><span class="token punctuation">)</span> <span class="token class-name">LayoutInflater</span><span class="token punctuation">.</span><span class="token function">from</span><span class="token punctuation">(</span>parent<span class="token punctuation">.</span><span class="token function">getContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">inflate</span><span class="token punctuation">(</span><span class="token class-name">R</span><span class="token punctuation">.</span>layout<span class="token punctuation">.</span>my_text_view<span class="token punctuation">,</span> parent<span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
        <span class="token class-name">MyViewHolder</span> vh <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MyViewHolder</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span>	<span class="token punctuation">;</span>
        <span class="token keyword">return</span> vh<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// 设置每一个项的内容</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onBindViewHolder</span><span class="token punctuation">(</span><span class="token class-name">MyViewHolder</span> holder<span class="token punctuation">,</span> <span class="token keyword">int</span> position<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// - get element from your dataset at this position</span>
        <span class="token comment">// - replace the contents of the view with that element</span>
        holder<span class="token punctuation">.</span>textView<span class="token punctuation">.</span><span class="token function">setText</span><span class="token punctuation">(</span>mDataset<span class="token punctuation">[</span>position<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token comment">// 返回数据集的数量</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getItemCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> mDataset<span class="token punctuation">.</span>length<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><ol start="4"><li>在Activity类中添加对RecyclerView的引用，设置布局管理器，绑定适配器</li> <li>如果数据集大小不会发生变化，建议 <code>recyclerView.setHasFixedSize(true);</code>设置view的数据集大小固定以提高性能</li></ol> <h2 id="fragment生命周期"><a href="#fragment生命周期" class="header-anchor">#</a> Fragment生命周期</h2> <div class="language-mermaid extra-class"><pre class="language-text"><code>graph TB
    1(&quot;onAttach()&quot;)--&gt;2(&quot;onCreate()&quot;)
    2--&gt;3(&quot;onCreateView()&quot;)
    3--&gt;4(&quot;onActivityCreated()&quot;)
    4--&gt;5(&quot;onStart()&quot;)
    5--&gt;6(&quot;onResume()&quot;)
    6--&gt;7(&quot;onPause()&quot;)
    7--&gt;8(&quot;onStop()&quot;)
    8--&gt;9(&quot;onDestroyView()&quot;)
    9--&gt;10(&quot;onDestroy()&quot;)
    10--&gt;11(&quot;onDetach()&quot;)
    
   
</code></pre></div><h2 id="访问网络"><a href="#访问网络" class="header-anchor">#</a> 访问网络</h2> <div class="language- extra-class"><pre class="language-text"><code>import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.Scanner;

public class TestJava {
    public static void main(String[] args) {

        try {
            URL url = new URL(&quot;https://rattonlzh.github.io/homepage/homepage.html&quot;);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod(&quot;GET&quot;);
            conn.setConnectTimeout(5000);//超时时间为5000毫秒
            if (200 == conn.getResponseCode()) {
                InputStream is = conn.getInputStream();// 获取服务器返回的输入流
                Scanner sc = new Scanner(is);
                StringBuilder sb = new StringBuilder();
                while (sc.hasNext()) {
                    sb.append(sc.nextLine());
                }
                System.out.println(sb);
            }
            conn.disconnect();
            sc.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
       
}
</code></pre></div><h2 id="handler-信息机制"><a href="#handler-信息机制" class="header-anchor">#</a> Handler 信息机制</h2> <p>android应用运行默认有一个主线程，你可以创建新的子线程，把访问网络等操作放在子线程进行，但是ui的更新必须在主线程中进行，因此需要一个主线程与子线程通信的机制，这就是android.os.Handler的作用。</p> <p>Handler主要运用 <code>handleMessage（android.os.Message）</code> 和 <code>sendMessage(android.os.Message)</code> 两个函数分别处理信息和街发送信息。</p> <p>在Activity中的<code>OnCreate（Bundle）</code>中实例化一个Handler对象，系统中默认存在一个Loop对象，因此在主线程中不需要手动调用 （<code>Looper.loop()</code>）开启信息循环，在实例化的时候编写 <code>handleMessage(android.os.Message)</code> 方法, 根据 <code>android.os.Message</code>的不同 写 <code>switch</code>控制语句，对不同信息 进行不同的操作。同时在子线程中，使用主线程实例化的Handler对象调用 <code>sendMessage(android.os.Message)</code>发送与该线程相关的信息</p> <h2 id="创建图片对象"><a href="#创建图片对象" class="header-anchor">#</a> 创建图片对象</h2> <p>使用 <code>BitmapFactory</code>类创建位图对象</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Bitmap</span> bitmap <span class="token operator">=</span> <span class="token class-name">BitmapFactory</span><span class="token punctuation">.</span><span class="token function">decodeFile</span><span class="token punctuation">(</span><span class="token string">&quot;/sdcard/ratton.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//根据文件创建位图对象</span>
<span class="token class-name">InputStream</span> fis <span class="token operator">=</span> <span class="token class-name">FileInputStream</span><span class="token punctuation">(</span><span class="token string">&quot;/sdcard/ratton.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
bitmap <span class="token operator">=</span> <span class="token class-name">BitmapFactory</span><span class="token punctuation">.</span><span class="token function">decodeStream</span><span class="token punctuation">(</span>fis<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//从输入流中创建位图对象</span>
bitmap <span class="token operator">=</span> <span class="token class-name">BitemapFactory</span><span class="token punctuation">.</span><span class="token function">decodeResource</span><span class="token punctuation">(</span><span class="token function">getResources</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">R</span><span class="token punctuation">.</span>id<span class="token punctuation">.</span>ratton<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 从给定的资源id，从指定资源中解析，创建位图对象</span>
</code></pre></div><h2 id="推荐的android应用架构"><a href="#推荐的android应用架构" class="header-anchor">#</a> 推荐的android应用架构</h2> <p><img src="/assets/img/android应用架构.03f418a8.jpg" alt="fragment+viewModel+roomDatabase"></p> <h2 id="uri与string互转"><a href="#uri与string互转" class="header-anchor">#</a> Uri与String互转</h2> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Uri</span> uri <span class="token operator">=</span> <span class="token class-name">Uri</span><span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">)</span> str<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// String转Uri</span>
<span class="token comment">// str的格式：content://xxxx或 file:///xxx或 http(s)://xxx 或ftp://xxx</span>

<span class="token class-name">String</span> str <span class="token operator">=</span> uri<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// Uri转String</span>
</code></pre></div><h2 id="animation"><a href="#animation" class="header-anchor">#</a> animation</h2> <h3 id="透明度渐变动画"><a href="#透明度渐变动画" class="header-anchor">#</a> 透明度渐变动画</h3> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>alpha</span>
       <span class="token attr-name"><span class="token namespace">android:</span>interpolator</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@android:anim/inear_interpolator<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">android:</span>repeatMode</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>reverse<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">android:</span>repeatCount</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>infinite<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">android:</span>duration</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>1000<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">android:</span>fromAlpha</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>1.0<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">android:</span>toAlpha</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span>
       <span class="token punctuation">/&gt;</span></span>
</code></pre></div><h3 id="缩放动画"><a href="#缩放动画" class="header-anchor">#</a> 缩放动画</h3> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>scale</span>
	<span class="token attr-name"><span class="token namespace">android:</span>repeatMode</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>reverse<span class="token punctuation">&quot;</span></span>
	<span class="token attr-name"><span class="token namespace">android:</span>repeatCount</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>infinite<span class="token punctuation">&quot;</span></span>
	<span class="token attr-name"><span class="token namespace">android:</span>duration</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>3000<span class="token punctuation">&quot;</span></span>
     <span class="token attr-name"><span class="token namespace">android:</span>fromXScale</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>1.0<span class="token punctuation">&quot;</span></span>
     <span class="token attr-name"><span class="token namespace">android:</span>fromYScale</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>1.0<span class="token punctuation">&quot;</span></span>
     <span class="token attr-name"><span class="token namespace">android:</span>toXScale</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.5<span class="token punctuation">&quot;</span></span>
     <span class="token attr-name"><span class="token namespace">android:</span>toYScale</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.5<span class="token punctuation">&quot;</span></span>
     <span class="token attr-name"><span class="token namespace">android:</span>pivotX</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50%<span class="token punctuation">&quot;</span></span>
     <span class="token attr-name"><span class="token namespace">android:</span>pivotY</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50%<span class="token punctuation">&quot;</span></span>
 	<span class="token punctuation">/&gt;</span></span>
</code></pre></div><h3 id="旋转动画"><a href="#旋转动画" class="header-anchor">#</a> 旋转动画</h3> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>rotate</span>
        <span class="token attr-name"><span class="token namespace">android:</span>fromDegree</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>toDegree</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>360<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>pivotX</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50%<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>pivotY</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50%<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>repeatMode</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>reverse<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>repeatCount</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>infinite<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>duration</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>1000<span class="token punctuation">&quot;</span></span>
        <span class="token punctuation">/&gt;</span></span>
</code></pre></div><h3 id="平移动画"><a href="#平移动画" class="header-anchor">#</a> 平移动画</h3> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>translate</span>
           <span class="token attr-name"><span class="token namespace">android:</span>fromXDelta</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span>
           <span class="token attr-name"><span class="token namespace">android:</span>fromYDelta</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span>
           <span class="token attr-name"><span class="token namespace">android:</span>toXDelta</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>100<span class="token punctuation">&quot;</span></span>
           <span class="token attr-name"><span class="token namespace">android:</span>toYDelta</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span>
           <span class="token attr-name"><span class="token namespace">android:</span>repeatMode</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>reverse<span class="token punctuation">&quot;</span></span>
           <span class="token attr-name"><span class="token namespace">android:</span>repeatCount</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>infinite<span class="token punctuation">&quot;</span></span>
           <span class="token punctuation">/&gt;</span></span>
</code></pre></div><h3 id="组合动画"><a href="#组合动画" class="header-anchor">#</a> 组合动画</h3> <p>将以上动画的标签都放在 <code>&lt;set&gt;</code>结点内</p> <h1 id="活用android-studio"><a href="#活用android-studio" class="header-anchor">#</a> 活用Android Studio</h1> <h2 id="阿里源镜像仓库"><a href="#阿里源镜像仓库" class="header-anchor">#</a> 阿里源镜像仓库</h2> <div class="language-groovy extra-class"><pre class="language-groovy"><code>ext <span class="token punctuation">{</span>
    var <span class="token operator">=</span> <span class="token string">'7.0.1'</span>
<span class="token punctuation">}</span>

<span class="token comment">// Top-level build file where you can add configuration options common to all sub-projects/modules.</span>


buildscript <span class="token punctuation">{</span>
    repositories <span class="token punctuation">{</span>
        maven<span class="token punctuation">{</span> url <span class="token string">'http://maven.aliyun.com/nexus/content/groups/public/'</span><span class="token punctuation">}</span>
        <span class="token function">mavenCentral</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">google</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">jcenter</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        
    <span class="token punctuation">}</span>
    dependencies <span class="token punctuation">{</span>
        classpath <span class="token string">'com.jakewharton:butterknife-gradle-plugin:10.2.0'</span>
        classpath <span class="token string">'com.android.tools.build:gradle:3.5.3'</span>
        classpath <span class="token string">'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.2'</span> <span class="token comment">//添加这一行</span>
        <span class="token comment">// NOTE: Do not place your application dependencies here; they belong</span>
        <span class="token comment">// in the individual module build.gradle files</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

allprojects <span class="token punctuation">{</span>
    repositories <span class="token punctuation">{</span>
        maven<span class="token punctuation">{</span> url <span class="token string">'http://maven.aliyun.com/nexus/content/groups/public/'</span><span class="token punctuation">}</span>
        maven <span class="token punctuation">{</span> url <span class="token string">'https://jitpack.io'</span> <span class="token punctuation">}</span>
        <span class="token function">google</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">jcenter</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">mavenCentral</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

task <span class="token function">clean</span><span class="token punctuation">(</span>type<span class="token punctuation">:</span> Delete<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    delete rootProject<span class="token punctuation">.</span>buildDir
<span class="token punctuation">}</span>

</code></pre></div><h2 id="注释保持缩进对齐"><a href="#注释保持缩进对齐" class="header-anchor">#</a> 注释保持缩进对齐：</h2> <p><code>Ctrl+Alt+S</code>打开设置。</p> <p>按 <code>Ctrl+/</code>注释保持缩进对齐： 转到<code>Editor&gt;Code Style&gt;Java&gt;Code Generation</code>选项卡，<code>Comment Code</code>选项组的 <code>Line comment at first column</code>和 <code>Blockcomment at first column</code> 取消打勾，<code>Add a space at comment start</code>打勾</p> <p>代码重新格式化时保持注释缩进对齐：转到<code>Editor&gt;Code Style&gt;Java&gt;Wrapping and Braces</code>选项卡，<code>Keep when reformatting</code>选项中的<code>Comment at first column</code>取消打勾</p> <h2 id="查看类的定义"><a href="#查看类的定义" class="header-anchor">#</a> 查看类的定义</h2> <p>按住 <code>ctrl</code>，点击类名，可以跳转到该类的定义（如果存在的话）。</p> <p>这在不清楚的某些类的构造函数时尤为有用。</p> <h1 id="提高效率的快捷键"><a href="#提高效率的快捷键" class="header-anchor">#</a> 提高效率的快捷键</h1> <p><img src="/assets/img/1576896143184.5f502f56.png" alt="1576896143184"></p> <p><img src="/assets/img/1576896179404.e86f738d.png" alt="1576896179404"></p> <p><img src="/assets/img/1576896191033.ddc16623.png" alt="1576896191033"></p> <p><img src="/assets/img/1576896281818.09b3c7de.png" alt="1576896281818"></p> <h2 id="使用resource-manager添加图片资源"><a href="#使用resource-manager添加图片资源" class="header-anchor">#</a> 使用resource manager添加图片资源</h2> <p><img src="/assets/img/1576896766324.dc586abf.png" alt="1576896766324"></p> <p><img src="/assets/img/1577071565188.a43bc1a6.png" alt="1577071565188"></p> <p><img src="/assets/img/1577071687161.24f91d64.png" alt="1577071687161"></p> <p><img src="/assets/img/1577071808595.263bb08e.png" alt="1577071808595"></p></div> <footer class="page-edit"><!----> <!----> <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh"><img alt="知识共享许可协议" src="" style="border-width:0"></a><br>本作品采用<a rel="license" href="http://creativecommons.org/licenses/by/4.0/">知识共享署名 4.0 国际许可协议</a>进行许可。

   
</footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/" class="prev">
        前言
      </a></span> <span class="next"><a href="/配置记录/apache服务器配置.html">
        apache服务器配置
      </a>
      →
    </span></p></div>  <footer style="text-align:center;"><a href="https://beian.miit.gov.cn">
    粤ICP备2021020303号</a></footer></main></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.54ea76a2.js" defer></script><script src="/assets/js/2.c554ece5.js" defer></script><script src="/assets/js/13.9096527c.js" defer></script>
  </body>
</html>
